/*
 * @lc app=leetcode.cn id=507 lang=javascript
 *
 * [507] 完美数
 */

// @lc code=start
/**
 * @param {number} num
 * @return {boolean}
 */
var checkPerfectNumber = function(num) {
    if (num === 1) {
        return false
    }
    let arr = []
    for (let index = 1; index < num; index++) {
        if (num % index === 0) {
            arr.push(index)
        }
    }
    return num === arr.reduce((a, b) => a + b)
};
// @lc code=end

